<!--
 * @Description: 
 * @Author: charles
 * @Date: 2020-11-03 14:04:56
 * @LastEditors: Please set LastEditors
<<<<<<< HEAD
 * @LastEditTime: 2021-07-07 15:37:23
-->

<template>
  <div>
    <div class="header">
      <div class="h_title">{{resData.data.name}}</div>
      <div class="h_date">{{fmtDate(resData.data.beginTime)}} ~ {{fmtDate(resData.data.endTime)}} | {{resData.data.region}}</div>
    </div>
    <div class="content" v-html="resData.data.details"></div>
    <div class="footer">
      <el-button type="primary" plain @click="goBackHandler">返回</el-button>
    </div>
    <div class="foot">
      <div>旅游攻略——课设3组，咨询热线：8888-888</div>
    </div>
  </div>
</template>
<script>
import request from '../utils/request'
import moment from 'moment';
export default {
  data() {
    return {
      id: null,
      resData: {}
    }
  },
  methods: {
    findProjectById() {
      request.get('/index/project/findById?id=' + this.id).then(res => {
        // 将成功返回的数据结果赋值给this.resData
        this.resData = res
      })
    },
    fmtDate(date) {
      return moment(date).format('YYYY-MM-DD HH:mm:ss')
    },
    // 点击返回按钮事件处理函数
    goBackHandler() {
      // go(-1)代表在浏览器的历史记录中，返回上一条记录
      this.$router.go(-1)
    }
  },
  created() {
    // 在当前钩子函数中接受路由跳转传递过来的参数
    // 把跳转携带过来的参数赋值给 this.id
    this.id = this.$route.query.id
    // id赋值完毕后，再执行请求项目详情的方法
    this.findProjectById()
  }
}
</script>
<style scoped>
.header {
  text-align: center;
}
.h_title {
  font-size: 22px;
  font-weight: bold;
  height: 50px;
  line-height: 50px;
}
.content {
  text-align: center;
  padding: 50px 100px;
  font-size: 18px;
  font-weight: bold;
}
.footer {
  text-align: center;
  height: 100px;
}
.foot{
  height: 50px;
  line-height: 50px;
  font-size: 15px;   
  font-family: cursive;
  text-align: center;
}
</style>